package org.protege.owl.examples.tab;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ErrorFrame extends JFrame
{
	ErrorFrame()
	{
		this.setLayout(new BorderLayout());
		this.setTitle("ERROR!");
		this.setPreferredSize(new Dimension(400,300));
		this.setMinimumSize(new Dimension(400,300));
		this.add(errorPane, BorderLayout.CENTER);
		okButton.setPreferredSize(new Dimension(30,30));
		this.add(okButton,BorderLayout.PAGE_END);
		okButton.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent arg0)
			{
				errorArea.setText("");
				setVisible(false);
			}});
		
		errorArea.setEditable(false);
		
		this.setVisible(false);
		
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	}
	
	public void addText(String message)
	{
		errorArea.append("\n"+message);
	}
	
	public void showError()
	{
		this.setVisible(true);
	}
	
	private JTextArea errorArea = new JTextArea();
	private JScrollPane errorPane = new JScrollPane(errorArea);
	private JButton okButton = new JButton("OK");
}
